﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using InternetModel;

namespace InternetDAL
{
    public class JurisdictionDAL
    {
        SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=ItemOne;Integrated Security=True");

        /// <summary>
        /// 管理员登录
        /// </summary>
        public int JurisdictionEnter(Jurisdiction news)
        {

            ////string sql = "select * from jurisdiction";
            ////SqlConnection conn = new SqlConnection(connstr);//创建字符串对象
            ////SqlCommand command = new SqlCommand(sql,conn);
            ////SqlDataAdapter adapter = new SqlDataAdapter(command);
            ////DataTable dt = new DataTable();
            ////adapter.Fill(dt);

            
            int num = 0;
         //   SqlConnection conn = new SqlConnection(connstr);//创建字符串对象
            conn.Open();
            SqlCommand command = new SqlCommand("JEnter", conn);//创建command命令
            command.CommandType = CommandType.StoredProcedure;//指定是存储过程
            SqlParameter[] par = {
                                                                  new SqlParameter("@JName",news.JName),
                                                                  new SqlParameter("@Jpwd",news.Jpwd),
                                                                  new SqlParameter("@num",SqlDbType.Int)
                                                              };//参数
            par[2].Direction = ParameterDirection.Output;
            command.Parameters.AddRange(par);
            
            SqlDataAdapter adapter = new SqlDataAdapter(command);
            DataTable dt = new DataTable();
            adapter.Fill(dt);

            //int result = Convert.ToInt32(command.ExecuteScalar());//返回单字符
            conn.Close();
            conn.Dispose();
            num = Convert.ToInt32(par[2].Value);
           
            return num;
        }
    
    }
    
}
